import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;


public class PortScanner {
	
	private int start;
	private int end;
	
	PortScanner(){
		start=1;
		end = 65535;
	}
	
	PortScanner(int start, int end){
		this.start = start;
		this.end = end;
	}

	public void scanAll(){
		for(int i = start; i < end; i++){
			try {
				Socket srvSocket = new Socket("127.0.0.1",i);
				
				System.out.println("Porta " + i + " em uso.");
				
				srvSocket.close();
			} catch (UnknownHostException e) {
			} catch (IOException e) {
			}
		}
		
		System.out.println("Scan finalizado.");
	}
}
